//
//  LGConsultPatientRepetionView.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/10/24.
//

#import "LGConsultPatientRepetionView.h"

@interface LGConsultPatientRepetionView()
/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UILabel *titleLabel;
/**   */
@property (nonatomic , strong)UILabel *contentLabel;
/**   */
@property (nonatomic , strong)UIButton *closeButton;
/**   */
@property (nonatomic , strong)UIButton *checkBtn;

@end

@implementation LGConsultPatientRepetionView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor colorWithString:@"#000000" alpha:0];
        [self addSubview:self.baseView];
        [self.baseView addSubview:self.titleLabel];
        [self.baseView addSubview:self.closeButton];
        [self.baseView addSubview:self.contentLabel];
        [self.baseView addSubview:self.checkBtn];
        [UIView animateWithDuration:0.4 animations:^{
            self.backgroundColor = [UIColor colorWithString:@"#000000" alpha:0.5];
            self.baseView.transform = CGAffineTransformScale(self.baseView.transform, 10000, 10000);
        }];
    }
    return self;
}

-(void)checkBtnAction{
    if(self.checkConsultRecord){
        self.checkConsultRecord();
    }
    [self closeViewAction];
}

-(void)closeViewAction{
    [UIView animateWithDuration:0.4 animations:^{
        self.backgroundColor = [UIColor colorWithString:@"#000000" alpha:0];
        self.baseView.transform = CGAffineTransformScale(self.baseView.transform, 0.0001, 0.0001);
    } completion:^(BOOL finished) {
        [self removeFromSuperview];
    }];
}

#pragma mark
#pragma mark ====> 创建控件
-(UIView *)baseView{
    if(!_baseView){
        _baseView = [[UIView alloc] initWithFrame:CGRectMake((Screen_W-viewPix(320))/2.0, (Screen_H-viewPix(212))/2.0, viewPix(320), viewPix(212))];
        _baseView.transform = CGAffineTransformScale(_baseView.transform, 0.0001, 0.0001);
        _baseView.backgroundColor = [UIColor whiteColor];
        _baseView.cornerRidus = 15;
    }
    return _baseView;
}

-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel lableWithText:@"提示" colorString:@"#333333" textFont:LGFontWeight(17, UIFontWeightMedium) textAlignment:NSTextAlignmentCenter lines:1];
        _titleLabel.frame = CGRectMake(0, viewPix(24), viewPix(320), viewPix(24));
    }
    return _titleLabel;
}

-(UIButton *)closeButton{
    if(!_closeButton){
        _closeButton = [UIButton buttonWithImage:@"closeGray16" selectImage:@"closeGray16"];
        _closeButton.frame = CGRectMake(viewPix(272), viewPix(12), viewPix(36), viewPix(36));
        [_closeButton addTarget:self action:@selector(closeViewAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _closeButton;
}
-(UILabel *)contentLabel{
    if(!_contentLabel){
        _contentLabel = [UILabel lableWithText:@"该患者今天已有咨询记录，无法重复创建" colorString:@"#333333" textFont:LGFont(17) textAlignment:NSTextAlignmentLeft lines:2];
        _contentLabel.frame = CGRectMake(viewPix(24), viewPix(72), viewPix(272), viewPix(48));
        [_contentLabel lineSpacing:5];
    }
    return _contentLabel;
}

-(UIButton *)checkBtn{
    if(!_checkBtn){
        _checkBtn = [UIButton buttonWithTitle:@"去查看" titleFont:LGFontWeight(16, UIFontWeightMedium) textColor:@"#FFFFFF" imageName:@""];
        _checkBtn.frame = CGRectMake(viewPix(24), viewPix(144), viewPix(272), viewPix(48));
        _checkBtn.backgroundColor = [UIColor colorWithString:@"#3291FF"];
        _checkBtn.cornerRidus = 10;
        [_checkBtn addTarget:self action:@selector(checkBtnAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _checkBtn;
}

@end
